package heven.holt.wan.android.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import heven.holt.library.base.BaseFragment
import heven.holt.library.adapter.CommonViewPagerAdapter
import heven.holt.wan.android.databinding.FragmentQaBinding

@AndroidEntryPoint
class QAFragment : BaseFragment<FragmentQaBinding>() {
    private val tabTexts = arrayOf("问答", "广场")
    private val fragments = listOf(QAQuizFragment(), QaSquareFragment())

    override fun bindViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): FragmentQaBinding = FragmentQaBinding.inflate(inflater, container, false)

    override fun initView() {
        binding.viewPager.adapter = CommonViewPagerAdapter(this, fragments)
        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            tab.text = tabTexts[position]
        }.attach()
    }

    override fun initData() {
    }
}